package com.study.springjdbc;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

/**
 * Created by 汪贵春 on 2017/2/25.
 */
public class TestMain {
    public static void main(String[] args) throws Exception {
        ApplicationContext context = new ClassPathXmlApplicationContext("spring-context.xml");
        JdbcTemplateDao dao = context.getBean("jdbcTemplateDao", JdbcTemplateDao.class);

//        dao.createTable();
//        dao.insertData();
        System.out.println(dao.count());

        List<User> list = dao.getUserList();
        for (User user : list) {
            System.out.println("id: " + user.getId() + " name:" + user.getFirstName() + " " + user.getLastName());
        }


        ((ConfigurableApplicationContext) context).close();

    }
}
